{% extends "base.html" %}
{% block title %}oozie任务监控{% endblock %}
{% block head %}
{% endblock %}
{% block contentheader %}Oozie任务{% endblock %}
{% block contentsmallheader %}监控由oozie调度的程序运行状况{% endblock %}
{% block content %}
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <div class="box-header with-border">
                    <h3 class="box-title fa fa-tv"> 已提交的Oozie任务( STATUS=RUNNING )</h3>
                    <div class="box-tools">
                        <button type="button" class="btn btn-box-tool" id="list_error">error
                        </button>
                        <button type="button" class="btn btn-box-tool" id="list_all">all
                        </button>
                        <button type="button" class="btn btn-box-tool " data-widget="collapse"><i
                                class="fa fa-minus"></i>
                        </button>
                    </div>
                </div>
                <div class="box-body no-padding" style="display: block;">
                    <ul class="nav nav-pills nav-stacked" id="task_list" style="overflow: auto;max-height: 700px">
                    </ul>
                </div>
            </div>
        </div>

    </div>

{% endblock %}
{% block script %}

    <script>
        function add_class() {
            $('#treeview4').addClass('active');
            $('#menu4').addClass('menu-open');
            $('#monitoroozie').addClass('active');
        }
        $("#task_detail").hide();
        var task_list;
        $.ajax({
            url: "/monitor_oozie_get_tasks", success: function (data) {

                for (var i = 0; i < data.data.length; i++) {
                    hue_url = data.oozie_url + data.data[i][0];
                    var from = "( " + data.data[i][6];
                    var freq = " | " + data.data[i][5];
                    var begin = " | " + data.data[i][3];
                    var over = " | " + data.data[i][7];
                    var end = from + freq + begin + over + ' )';
                    var info = "<span class='label label-primary pull-right'>" + end + "</span><span class='pull-right'>&nbsp;</span>";
                    if (data.data[i][9] == 0)
                        $("#task_list").append("<li class='t_ok' data-target='" + data.data[i][0] + "'><a href='" + hue_url + "'><i class='fa fa-tasks'></i> " + data.data[i][1] + info + "</a></li>");
                    else
                        $("#task_list").append("<li data-target='" + data.data[i][0] + "'><a href='" + hue_url + "'><i class='fa fa-tasks'></i> " + data.data[i][1] + info + "<span class='label label-danger pull-right'>" + data.data[i][9] + " ( 7 days )</span>  </a></li>");
                }
                $('.t_ok').hide();
            }
        });
        $('#list_error').on('click', function () {
            $('.t_ok').hide();
        });
        $('#list_all').on('click', function () {
            $('.t_ok').show();
        });
    </script>
{% endblock %}
